#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>

typedef struct PDU
{
  int a;
  int b;
  int c;
  int d[];//sizeof的时候不占用空间, 因为没有数据, 没有分配给它空间
}PDU;


int main()
{
    printf("Hello World!\n");
    printf("%ld\n", (long)sizeof(PDU));

    //给PDU的 int d[]; 数据添加空间
    PDU * pdu = (PDU*)malloc(sizeof(PDU)+ 100*sizeof (int));

    //测试
    pdu->a = 10;
    pdu->b = 20;
    pdu->c = 30;

    memcpy(pdu->d, "you jump, i jump", 17);

    printf("a=%d\n", pdu->a);
    printf("b=%d\n", pdu->b);
    printf("c=%d\n", pdu->c);
    printf("d=%s\n", (char*)(pdu->d));

    //使用完毕释放
    free(pdu);
    pdu = NULL;

    return 0;
}
